import json

from ronglian_sms_sdk import SmsSDK

accId = '8a216da873cec1320173fb4bf6760f33'
accToken = '0d81bbfa9b2e44db88ae1a703cc4082e'
appId = '8a216da873cec1320173fb4bf7690f3a'



def send_message(phone, datas):
    sdk = SmsSDK(accId, accToken, appId)
    tid = '1'  # 测试模板id为: 1. 内容为: 【云通讯】您的验证码是{1}，请于{2}分钟内正确输入。
    # mobile = '17730804936'
    # datas = ('666777', '5')  # 模板中的参数按照位置传递
    resp = sdk.sendMessage(tid, phone, datas)
    # json.loads()用于将str类型的数据转成dict。
    resp_dict=json.loads(resp)
    if resp_dict.get('statusCode')=='000000':
        return '0'
    else:
        return '-1'
    # return resp
# if __name__ == '__main__':
#     print(send_message('17730804936', ('1234', '5')))
